using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Rapier.Kodachi.SystemCommands.Actions
{
    public class LockComputer : Action
    {
        [DllImport("user32.dll")]
        public static extern void LockWorkStation(); 

       private Bitmap lockImage; 

        #region Constructor
        public LockComputer(Plugin plugin)
            : base(plugin, "Rapier.Kodachi.SystemCommands.LockComputer", "Lock Workstation", "Lock the workstation.")
        {
            lockImage = Rapier.Kodachi.SystemCommands.Properties.Resources.Lock.ToBitmap();
            this.IndirectItemUse = IndirectItemUse.None;
            GetImage = delegate()
            {
               return lockImage;
            };
        }
        #endregion

        #region Action Members
        public override void Execute(Item[] directItems, Item[] indirectItems)
        {
            LockWorkStation();
        }

        public override bool IsValidIndirect(Item indirectItem)
        {
            return false;
        }

        public override bool IsValidDirect(Item directItem)
        {
            return directItem.Properties.ContainsKey("SystemCommand") && (bool)(directItem.Properties["SystemCommand"]) == true;
        }
        #endregion
    }
}
